'use strict';

/* Controllers */

angular.module('myApp.controllersPlayer', [])
        .controller('PlayersCtrl',  ['$scope', '$location',
                                    '$firebase', 'serviceFirebaseUsers',
                                    'serviceGame', 'serviceUser',
            function($scope, location, $firebase, firebaseUsers, game, user) {
                
                var ref = firebaseUsers.getActiveUsersRef();
                $scope.users = $firebase(ref);
                $scope.userObj = user;
                
                $scope.createGame = function(userData) {
                    console.log(userData);
                    if (userData.email == user.email) {
                        $('#popupError').modal('show');
                    } else {
                        game.playerUserTmp = userData;
                        location.path('/game/play/owner');
                        console.log('redirect');
                    }
                }
            }
        ])
        .controller('GamesCtrl', ['$scope', '$rootScope',
            function($scope) {

            }
        ]);